package math;

import io.GPSPoint;

import java.util.ArrayList;
import java.util.List;

public class StatisticsFactory {

	public List<StatisticProvider> getProviders(List<GPSPoint> gpsTracks) {
		List<StatisticProvider> providers = new ArrayList<StatisticProvider>();
		if (gpsTracks == null) {
			return providers;
		}
		providers.add(new DistanceCalculator(1));
		providers.add(new DistanceCalculator(5));
		providers.add(new DistanceCalculator(10));
		providers.add(new ElevationProvider());
		GPSPoint firstPoint = gpsTracks.get(0); //TODO the List<GPSPoint> should be replaced by a more clever structure
		if (firstPoint.getSpeed() >= 0) { 
			SensorSpeedProvider speedProvider = new SensorSpeedProvider();
			providers.add(speedProvider);
			providers.add(new SimpleAverager(speedProvider, new Averagers.Median()));
			//providers.add(new SimpleAverager(speedProvider, new Averagers.Mean()));
		}
		if (firstPoint.getHeartRate() >= 0) { 
			providers.add(new HeartRateProvider());
		}
		CalculatedPaceProvider pace = new CalculatedPaceProvider();
		providers.add(pace);
		providers.add(new SimpleAverager(pace, new Averagers.Median()));
		return providers;
	}
}
